<template>
  <div class="home">
    <el-container>
      <el-header>
        <div></div>
        <div class="header-right">
          <el-dropdown @command="click">
            <el-button type="primary">
              更多菜单<i class="el-icon-arrow-down el-icon--right"></i>
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>黄金糕</el-dropdown-item>
              <el-dropdown-item>狮子头</el-dropdown-item>
              <el-dropdown-item>螺蛳粉</el-dropdown-item>
              <el-dropdown-item>双皮奶</el-dropdown-item>
              <el-dropdown-item command="out">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <el-menu
            default-active="2"
            class="el-menu-vertical-demo"
            background-color="#545c64"
            text-color="#fff"
            active-text-color="#ffd04b"
          >
            <el-submenu
              v-for="(item, index) in filterRoutes[0].children"
              :key="index"
              :index="index + 1 + ''"
            >
              <template slot="title">
                <span>{{ item.title }}</span>
              </template>
              <el-menu-item-group
                v-for="(items, indexs) in item.children"
                :key="indexs"
              >
                <el-menu-item :index="index + 1 + '-' + (indexs + 1)">
                  <router-link
                    tag="span"
                    :to="'/home/' + item.path + '/' + items.path"
                    >{{ items.title }}
                  </router-link>
                </el-menu-item>
              </el-menu-item-group>
            </el-submenu>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view />
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  computed: {
    ...mapState(["filterRoutes"]),
  },
  created() {
    console.log("我用来调试");
  },
  methods: {
    click(command) {
      F;
      switch (command) {
        case "out":
          sessionStorage.removeItem("token");
          this.$router.push("/login");
          break;
        default:
          return false;
      }
    },
  },
};
</script>

<style scoped>
.header-right {
  float: right;
}

.el-header {
  background: #fff !important;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.19) !important;
  position: relative !important;
  top: 0 !important;
  width: 100% !important;
  z-index: 100 !important;
}

.el-header,
.el-footer {
  background-color: #b3c0d1;
  color: #333;
  line-height: 60px;
}

.el-container {
  height: 100% !important;
}

.el-aside {
  background-color: rgb(84, 92, 100);
  color: #333;
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
}

.home {
  height: 100%;
}

.el-dropdown {
  vertical-align: top;
}
.el-dropdown + .el-dropdown {
  margin-left: 15px;
}
.el-icon-arrow-down {
  font-size: 12px;
}
</style>